<template>
    <div class="audit-page">
      <!-- 顶部标题 -->
      <el-page-header content="资质审核状态" @back="goBack"></el-page-header>
  
      <!-- 审核状态 -->
      <div class="audit-status">
        <el-card>
          <div v-if="auditStatus === 0" class="status-info">
            <el-icon><el-icon-loading /></el-icon>
            <span>您的资质正在审核中，请耐心等待...</span>
          </div>
          <div v-else-if="auditStatus === 2" class="status-info">
            <el-icon><el-icon-warning /></el-icon>
            <span>审核未通过：</span>
            <p>{{ rejectionReason }}</p>
          </div>
          <div v-else="auditStatus === 1"   class="status-info">
            <el-icon><el-icon-success /></el-icon>
            <span>审核通过！您可以使用系统完整功能。</span>
          </div>
        </el-card>
      </div>
  
      <!-- 操作按钮 -->
      <div class="action-buttons">
        <el-button
          v-if="auditStatus === 2"
          type="primary"
          @click="goToReupload"
        >
          重新上传资料
        </el-button>
        <el-button type="default" @click="goToHome">返回首页</el-button>
        <el-button type="info" @click="contactSupport">联系客服</el-button>
      </div>
    </div>
  </template>
  
  <script>
  export default {
    data() {
      return {
        auditStatus: 0, // 审核状态（0: 审核中, 1: 通过, 2: 驳回）
        rejectionReason: "", // 审核驳回原因
      };
    },
    created() {
      this.fetchAuditStatus(); // 页面加载时获取审核状态
    },
    methods: {
      // 获取审核状态
      fetchAuditStatus() {
        this.$http
          .get("/market/shopApplication/getShopApplicationState", {
          })
          .then((response) => {
            const data = response.data;
            this.auditStatus = data.data.checkStatus; // 设置审核状态
            this.rejectionReason = data.data.rejectionReason || ""; // 设置驳回原因
          })
          .catch((error) => {
            console.error("获取审核状态失败", error);
            this.$message.error("无法获取审核状态，请稍后重试！");
          });
      },
      // 返回上一页
      goBack() {            
        this.$router.go(-1);
      },
      //重新上传资料
      goToReupload() {
        this.$router.push("/shopapplication");
      },
      // 返回登录
      goToHome() {
        this.$router.push("/shophome");
      },
      // 联系客服
      contactSupport() {
        this.$message.info("请拨打客服热线：400-123-4567");
      },
    },
  };
  </script>
  
  <style scoped>
  .audit-page {
    padding: 20px;
  }
  .audit-status {
    margin-bottom: 20px;
  }
  .status-info {
    display: flex;
    align-items: center;
    font-size: 16px;
  }
  .action-buttons {
    display: flex;
    justify-content: space-between;
  }
  </style>